/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.eclipse.iota.model;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.iota.IotaPackage;

/**
 * <!-- begin-user-doc -->
 * A representation of the model object '<em><b>Sequent</b></em>'.
 * <!-- end-user-doc -->
 *
 * <p>
 * The following features are supported:
 * <ul>
 *   <li>{@link org.eclipse.iota.model.Sequent#getPremise <em>Premise</em>}</li>
 *   <li>{@link org.eclipse.iota.model.Sequent#getConclusion <em>Conclusion</em>}</li>
 *   <li>{@link org.eclipse.iota.model.Sequent#getProof <em>Proof</em>}</li>
 * </ul>
 * </p>
 *
 * @see org.eclipse.iota.IotaPackage#getSequent()
 * @model kind="class"
 * @generated
 */
public class Sequent extends Definition {
	
	/**
	 * @generated NOT
	 * @param name Name of the sequent.
	 * @param parameters Parameters of the sequent.
	 */
	public Sequent(String name, Parameter... parameters) {
		super(name, parameters);
	}	

	/**
	 * @generated NOT
	 */
	@Override
	public String toString() {
		String result = "sequent " + super.toString() + "\n";
		result = result + getPremise() + " => " +getConclusion() + "\n";
		return result + ((proof!=null) ? proof : ";\n"); 
	}
	
	/* ---------------------------------------------------------------- *
	 * GENERATED CODE.                                                  *
	 * Do not edit below this line. If you need to edit, move it above  *
	 * this line and change the '@generated'-tag to '@generated NOT'.   *
	 * ---------------------------------------------------------------- */	

	/**
	 * The cached value of the '{@link #getPremise() <em>Premise</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPremise()
	 * @generated
	 * @ordered
	 */
	protected Alternation premise;

	/**
	 * The cached value of the '{@link #getConclusion() <em>Conclusion</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getConclusion()
	 * @generated
	 * @ordered
	 */
	protected Alternation conclusion;

	/**
	 * The cached value of the '{@link #getProof() <em>Proof</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getProof()
	 * @generated
	 * @ordered
	 */
	protected Proof proof;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Sequent() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return IotaPackage.Literals.SEQUENT;
	}

	/**
	 * Returns the value of the '<em><b>Premise</b></em>' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>Premise</em>' containment reference.
	 * @see #setPremise(Alternation)
	 * @see org.eclipse.iota.IotaPackage#getSequent_Premise()
	 * @model containment="true"
	 * @generated
	 */
	public Alternation getPremise() {
		return premise;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetPremise(Alternation newPremise, NotificationChain msgs) {
		Alternation oldPremise = premise;
		premise = newPremise;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, IotaPackage.SEQUENT__PREMISE, oldPremise, newPremise);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * Sets the value of the '{@link org.eclipse.iota.model.Sequent#getPremise <em>Premise</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>Premise</em>' containment reference.
	 * @see #getPremise()
	 * @generated
	 */
	public void setPremise(Alternation newPremise) {
		if (newPremise != premise) {
			NotificationChain msgs = null;
			if (premise != null)
				msgs = ((InternalEObject)premise).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - IotaPackage.SEQUENT__PREMISE, null, msgs);
			if (newPremise != null)
				msgs = ((InternalEObject)newPremise).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - IotaPackage.SEQUENT__PREMISE, null, msgs);
			msgs = basicSetPremise(newPremise, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, IotaPackage.SEQUENT__PREMISE, newPremise, newPremise));
	}

	/**
	 * Returns the value of the '<em><b>Conclusion</b></em>' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>Conclusion</em>' containment reference.
	 * @see #setConclusion(Alternation)
	 * @see org.eclipse.iota.IotaPackage#getSequent_Conclusion()
	 * @model containment="true"
	 * @generated
	 */
	public Alternation getConclusion() {
		return conclusion;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetConclusion(Alternation newConclusion, NotificationChain msgs) {
		Alternation oldConclusion = conclusion;
		conclusion = newConclusion;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, IotaPackage.SEQUENT__CONCLUSION, oldConclusion, newConclusion);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * Sets the value of the '{@link org.eclipse.iota.model.Sequent#getConclusion <em>Conclusion</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>Conclusion</em>' containment reference.
	 * @see #getConclusion()
	 * @generated
	 */
	public void setConclusion(Alternation newConclusion) {
		if (newConclusion != conclusion) {
			NotificationChain msgs = null;
			if (conclusion != null)
				msgs = ((InternalEObject)conclusion).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - IotaPackage.SEQUENT__CONCLUSION, null, msgs);
			if (newConclusion != null)
				msgs = ((InternalEObject)newConclusion).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - IotaPackage.SEQUENT__CONCLUSION, null, msgs);
			msgs = basicSetConclusion(newConclusion, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, IotaPackage.SEQUENT__CONCLUSION, newConclusion, newConclusion));
	}

	/**
	 * Returns the value of the '<em><b>Proof</b></em>' containment reference.
	 * It is bidirectional and its opposite is '{@link org.eclipse.iota.model.Proof#getSequent <em>Sequent</em>}'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>Proof</em>' containment reference.
	 * @see #setProof(Proof)
	 * @see org.eclipse.iota.IotaPackage#getSequent_Proof()
	 * @see org.eclipse.iota.model.Proof#getSequent
	 * @model opposite="sequent" containment="true"
	 * @generated
	 */
	public Proof getProof() {
		return proof;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetProof(Proof newProof, NotificationChain msgs) {
		Proof oldProof = proof;
		proof = newProof;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, IotaPackage.SEQUENT__PROOF, oldProof, newProof);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * Sets the value of the '{@link org.eclipse.iota.model.Sequent#getProof <em>Proof</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>Proof</em>' containment reference.
	 * @see #getProof()
	 * @generated
	 */
	public void setProof(Proof newProof) {
		if (newProof != proof) {
			NotificationChain msgs = null;
			if (proof != null)
				msgs = ((InternalEObject)proof).eInverseRemove(this, IotaPackage.PROOF__SEQUENT, Proof.class, msgs);
			if (newProof != null)
				msgs = ((InternalEObject)newProof).eInverseAdd(this, IotaPackage.PROOF__SEQUENT, Proof.class, msgs);
			msgs = basicSetProof(newProof, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, IotaPackage.SEQUENT__PROOF, newProof, newProof));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case IotaPackage.SEQUENT__PROOF:
				if (proof != null)
					msgs = ((InternalEObject)proof).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - IotaPackage.SEQUENT__PROOF, null, msgs);
				return basicSetProof((Proof)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case IotaPackage.SEQUENT__PREMISE:
				return basicSetPremise(null, msgs);
			case IotaPackage.SEQUENT__CONCLUSION:
				return basicSetConclusion(null, msgs);
			case IotaPackage.SEQUENT__PROOF:
				return basicSetProof(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case IotaPackage.SEQUENT__PREMISE:
				return getPremise();
			case IotaPackage.SEQUENT__CONCLUSION:
				return getConclusion();
			case IotaPackage.SEQUENT__PROOF:
				return getProof();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case IotaPackage.SEQUENT__PREMISE:
				setPremise((Alternation)newValue);
				return;
			case IotaPackage.SEQUENT__CONCLUSION:
				setConclusion((Alternation)newValue);
				return;
			case IotaPackage.SEQUENT__PROOF:
				setProof((Proof)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case IotaPackage.SEQUENT__PREMISE:
				setPremise((Alternation)null);
				return;
			case IotaPackage.SEQUENT__CONCLUSION:
				setConclusion((Alternation)null);
				return;
			case IotaPackage.SEQUENT__PROOF:
				setProof((Proof)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case IotaPackage.SEQUENT__PREMISE:
				return premise != null;
			case IotaPackage.SEQUENT__CONCLUSION:
				return conclusion != null;
			case IotaPackage.SEQUENT__PROOF:
				return proof != null;
		}
		return super.eIsSet(featureID);
	}

} // Sequent
